//
//  PlayerView.m
//  SuperRadio
//
//  Created by Damon on 14/12/28.
//  Copyright (c) 2014年 三个臭皮匠. All rights reserved.
//

#import "PlayerView.h"
#import "AudioButton.h"
@implementation PlayerView


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        CGFloat width = frame.size.width / 5;
        CGFloat height = frame.size.height / 10;
        
        // 进度条
        self.slider = [[UISlider alloc] initWithFrame:CGRectMake(5, 0, frame.size.width - 10, frame.size.height)];
        self.slider.center = CGPointMake(frame.size.width / 2, height / 2);
        [self addSubview:self.slider];
        [_slider release];
        
        // 进度时间
        self.currentTime =[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 50, height)];
        self.currentTime.center = CGPointMake(self.currentTime.frame.size.width / 2 + 10, height + height );
        self.currentTime.textAlignment = NSTextAlignmentLeft;
       // self.currentTime.text = @"00:00";
        [self addSubview:self.currentTime];
        [_currentTime release];
        
        // 总时间
        self.totalTime = [[UILabel alloc] initWithFrame:CGRectMake(frame.size.width - 60, 60, 50, height)];
        self.totalTime.center = CGPointMake(frame.size.width - self.totalTime.frame.size.width / 2 - 10, height + height);
        self.totalTime.textAlignment = NSTextAlignmentRight;
       // self.totalTime.text = @"15:23";
        [self addSubview:self.totalTime];
        [_totalTime release];
        
        
        self.audioButton = [[AudioButton alloc] init];
        self.audioButton.frame = CGRectMake(0, 0, height * 5, height * 5);
        self.audioButton.center = CGPointMake(frame.size.width / 2, height * 5 + height / 2);
        
        [self addSubview:self.audioButton];
        [_audioButton release];
        
        // 播放按钮
        self.playModelButton = [UIButton buttonWithType:UIButtonTypeSystem];
        self.playModelButton.frame = CGRectMake(20, 0, height + 10, height + 10);
       // [self.playModelButton setTitle:@"循环" forState:UIControlStateNormal];
        self.playModelButton.center = CGPointMake(width / 2, height * 5 + height / 2);
        [self addSubview:self.playModelButton];
        
        
        // 分享按钮
        self.shareButton = [UIButton buttonWithType:UIButtonTypeSystem];
        self.shareButton.frame = CGRectMake(width * 4, 0, height + 10, height + 10);
        self.shareButton.center = CGPointMake(width * 4 + width / 2, height * 5 + height / 2);
      //  [self.shareButton setTitle:@"分享" forState:UIControlStateNormal];
        [self addSubview:self.shareButton];
        
        
        // 下一首按钮
        self.upButton = [UIButton buttonWithType:UIButtonTypeSystem];
        self.upButton.frame = CGRectMake(width, 0, height * 3, height * 3);
        self.upButton.center = CGPointMake(width + width / 2, height * 5 + height / 2);
       // [self.upButton setTitle:@"上一曲" forState:UIControlStateNormal];
        [self addSubview:self.upButton];
        
        
        // 上一首按钮
        self.nextButton = [UIButton buttonWithType:UIButtonTypeSystem];
        self.nextButton.frame = CGRectMake(0, 0, height * 3, height * 3);
        self.nextButton.center = CGPointMake(width * 3 + width / 2, height * 5 + height / 2);
        //[self.nextButton setTitle:@"上一曲" forState:UIControlStateNormal];
        [self addSubview:self.nextButton];
        

    }
    return self;
    
}

- (void)dealloc
{
    [_audioButton release];
    [_currentTime release];
    [_totalTime release];
    [_slider release];
    [super dealloc];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
